<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>冷库温湿度监控</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/css/animate.min.css}">
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrap-table.min.css}">
    <link rel="stylesheet" th:href="@{/css/jquery.dataTables.min.css}">
    <link rel="stylesheet" th:href="@{/css/buttons.dataTables.min.css}">
    <style>
        .card {
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
        }
        .card-header {
            background-color: #f8f9fa;
            border-bottom: 1px solid #e9ecef;
            padding: 15px 20px;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
        }
        .card-body {
            padding: 20px;
        }
        .monitor-card {
            border-radius: 8px;
            margin-bottom: 20px;
            transition: all 0.3s ease;
        }
        .monitor-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        .monitor-header {
            padding: 15px;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
            color: white;
        }
        .monitor-body {
            padding: 15px;
            background-color: white;
            border-bottom-left-radius: 8px;
            border-bottom-right-radius: 8px;
        }
        .monitor-normal .monitor-header {
            background-color: #28a745;
        }
        .monitor-warning .monitor-header {
            background-color: #ffc107;
        }
        .monitor-danger .monitor-header {
            background-color: #dc3545;
        }
        .monitor-value {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 5px;
        }
        .monitor-label {
            font-size: 14px;
            color: #6c757d;
        }
        .monitor-time {
            font-size: 12px;
            color: #6c757d;
            margin-top: 10px;
        }
        .alarm-badge {
            position: absolute;
            top: 10px;
            right: 10px;
            padding: 5px 10px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: bold;
            color: white;
        }
        .alarm-badge-warning {
            background-color: #ffc107;
        }
        .alarm-badge-danger {
            background-color: #dc3545;
        }
        .chart-container {
            height: 300px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body class="gray-bg">
    <div id="content-wrapper" class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-title">
                        <h5>冷库温湿度监控中心</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="#" class="dropdown-item">选项 1</a></li>
                                <li><a href="#" class="dropdown-item">选项 2</a></li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row mb-4">
                            <div class="col-md-3">
                                <select id="warehouseSelect" class="form-control">
                                    <option value="">选择仓库</option>
                                </select>
                            </div>
                            <div class="col-md-3">
                                <button type="button" class="btn btn-primary" id="refreshBtn">
                                    <i class="fa fa-refresh"></i> 刷新数据
                                </button>
                            </div>
                        </div>
                        
                        <!-- 监控数据统计 -->
                        <div class="row mb-4">
                            <div class="col-md-3">
                                <div class="card">
                                    <div class="card-body text-center">
                                        <h2 id="normalCount">0</h2>
                                        <p>正常监控点</p>
                                        <div class="progress">
                                            <div class="progress-bar bg-success" id="normalProgress" style="width: 0%"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="card">
                                    <div class="card-body text-center">
                                        <h2 id="warningCount">0</h2>
                                        <p>预警监控点</p>
                                        <div class="progress">
                                            <div class="progress-bar bg-warning" id="warningProgress" style="width: 0%"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="card">
                                    <div class="card-body text-center">
                                        <h2 id="dangerCount">0</h2>
                                        <p>告警监控点</p>
                                        <div class="progress">
                                            <div class="progress-bar bg-danger" id="dangerProgress" style="width: 0%"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="card">
                                    <div class="card-body text-center">
                                        <h2 id="totalCount">0</h2>
                                        <p>总监控点</p>
                                        <div class="progress">
                                            <div class="progress-bar bg-info" style="width: 100%"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 实时监控数据 -->
                        <div class="card">
                            <div class="card-header">
                                <h5>实时监控数据</h5>
                            </div>
                            <div class="card-body">
                                <div class="row" id="monitorCards">
                                    <!-- 监控卡片将通过JavaScript动态生成 -->
                                </div>
                            </div>
                        </div>
                        
                        <!-- 温湿度趋势图 -->
                        <div class="card">
                            <div class="card-header">
                                <h5>温湿度趋势</h5>
                            </div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div id="temperatureChart" class="chart-container"></div>
                                    </div>
                                    <div class="col-md-6">
                                        <div id="humidityChart" class="chart-container"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 告警记录表格 -->
                        <div class="card">
                            <div class="card-header">
                                <h5>告警记录</h5>
                            </div>
                            <div class="card-body">
                                <table id="alarmTable" class="display table table-striped table-bordered" style="width:100%">
                                    <thead>
                                        <tr>
                                            <th>监控ID</th>
                                            <th>仓库名称</th>
                                            <th>存储区域</th>
                                            <th>设备ID</th>
                                            <th>温度</th>
                                            <th>湿度</th>
                                            <th>告警信息</th>
                                            <th>记录时间</th>
                                            <th>处理状态</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <!-- 表格数据将通过JavaScript动态生成 -->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 告警处理模态框 -->
    <div class="modal fade" id="processModal" tabindex="-1" role="dialog" aria-labelledby="processModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="processModalLabel">处理告警</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form id="processForm">
                        <input type="hidden" id="monitorId" name="monitorId">
                        <div class="form-group">
                            <label for="alarmInfo">告警信息</label>
                            <input type="text" class="form-control" id="alarmInfo" readonly>
                        </div>
                        <div class="form-group">
                            <label for="processRemark">处理备注</label>
                            <textarea class="form-control" id="processRemark" name="processRemark" rows="3" required></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="saveProcessBtn">保存</button>
                </div>
            </div>
        </div>
    </div>

    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/bootstrap.bundle.min.js}"></script>
    <script th:src="@{/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/js/dataTables.buttons.min.js}"></script>
    <script th:src="@{/js/buttons.html5.min.js}"></script>
    <script th:src="@{/js/echarts.min.js}"></script>
    <script th:src="@{/js/moment.min.js}"></script>
    <script th:src="@{/js/warehouse/coldStorageMonitor.js}"></script>
</body>
</html> 